package CommonApplicationLayer;

import SEG_EntityLayer.SEG_ModuloEL;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.border.EmptyBorder;


public class RenderListaModulo extends JLabel implements ListCellRenderer {

    public RenderListaModulo() {
    }
    
    @Override
    public Component getListCellRendererComponent(JList list, Object value,int index, boolean isSelected, boolean cellHasFocus) {
        SEG_ModuloEL modulo = (SEG_ModuloEL) value;
        ImageIcon icono = new ImageIcon(this.getClass().getResource("/Resources/application.png"));
        
        if ( this.getClass().getResource("/Resources/"+modulo.getIcono()) != null ) {
            icono = new ImageIcon(this.getClass().getResource("/Resources/"+modulo.getIcono()));
        }
        if ( isSelected ) {
            this.setBackground(new Color(51,153,255));
            this.setForeground(new Color(255,255,255));
        }
        else {
            this.setBackground(new Color(255,255,255));
            this.setForeground(new Color(0,0,0));
        }
        this.setFont(new Font("Lucida Fax", 0, 10));
        this.setBorder(new EmptyBorder(4,4,4,4));
        this.setOpaque(true);
        this.setIconTextGap(12);
        this.setText(modulo.getNombre());
        this.setToolTipText(modulo.getTooltip());
        this.setIcon(icono);
        
        return this;
    }
    
}
